
#include <string>
#include <QThread>
#include <QMutex>
#include <QMutexLocker>

class Account;
class UserHandler;
class UserCallback;

/**
 * handler all the account init and all the sip related init
 */

class UserProfile //: public QThread
{
public:

    static UserProfile *getInstance()
    {
        QMutexLocker locker(&m_mutex);
        if(m_userProfile == 0)
        {
            m_userProfile = new UserProfile();
        }
        return m_userProfile;
    }

    UserProfile();

    ~UserProfile();

    int setupAccount(std::string username, std::string password);

    Account *getUserAccount() const
    {
        return m_account;
    }

    UserHandler *getUserHandler() const
    {
        return m_userHandler;
    }

    bool isAccountSet() const
    {
        return m_accountSet;
    }


private:

    int initAccount(std::string username, std::string password);

    int initUserHandler();

    static UserProfile *m_userProfile;

    Account *m_account;

    UserHandler *m_userHandler;

    UserCallback *m_userCallback;

    std::string m_username;

    std::string m_password;

    static QMutex m_mutex;

    bool m_accountSet;

    //int initUserCallback();


};
